package com.xiaoke.controller;

import com.xiaoke.domain.ResponseResult;
import com.xiaoke.domain.dto.GetArticleListDTO;
import com.xiaoke.service.ArticleService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


/**
 * 文章表(Article)表控制层
 *
 * @author xiaoke
 * @since 2023-03-16 22:23:53
 */
@RestController
@RequestMapping("/article")
public class ArticleController {

    @Resource
    ArticleService articleService;

    /**
     * 获取热门文章
     */
    @GetMapping("/hostArticle")
    public ResponseResult hostArticle() {
        return articleService.hostArticle();
    }

    /**
     * 获取文章列表
     */
    @GetMapping("/getArticleList")
    public ResponseResult getArticleList(@Validated GetArticleListDTO getArticleListDTO) {
        return articleService.getArticleList(getArticleListDTO);
    }

    /**
     * 根据标签ID获取文章列表
     */
    @GetMapping("/getByTagIdArticleList/{id}")
    public ResponseResult getByTagIdArticleList(@PathVariable Long id) {
        return  articleService.getByTagIdArticleList(id);
    }

    /**
     * 根据分类ID获取文章列表
     */
    @GetMapping("/getByCategoryIdArticleList/{id}")
    public ResponseResult getByCategoryIdArticleList(@PathVariable Long id) {
        return  articleService.getByCategoryIdArticleList(id);
    }

    /**
     * 根据内容模糊查询
     */
    @GetMapping("/getByValueArticleList/{value}")
    public ResponseResult getByValueArticleList(@PathVariable String value) {
        return  articleService.getByValueArticleList(value);
    }

    /**
     * 获取ID获取文章
     */
    @GetMapping("/getArticle/{id}")
    public ResponseResult getArticle(@PathVariable String id) {
        return  articleService.getArticle(id);
    }
}
